<template>
	<view class="pos-r">
		<view v-if="isbool(data)">
			<view class="fs12 fwb">{{data.title}}</view>
			<view class="padtb2 ">
				<view class="flex-r flex-start lh2 bdbdo pad2 pos-r" :class="selectItem == item?'bg-green fs14':''" v-for="item in data.choices"
				 @tap="selectChoice(item)">
					<view class="flex1">{{item[0]}}</view>
					<view class="fwb fs14 text-green round cu-btn">{{item[1]}}</view>
					<ripple></ripple>
				</view>
			</view>
			<view class="mart5">
				<view class="list-style-2">其他信息</view>
				<view class="mart3">
					<stext label="备注说明" v-model="tips"></stext>
				</view>
				<view class="mart3">
					<spics label="图片附件" v-model="picsAttach"></spics>
				</view>
			</view>
			<view class="mart3">
				<view class="cu-btn lg w100 round" @tap="finish">
					保存结果
					<ripple></ripple>
				</view>
			</view>
		</view>

		<view class="pad10" v-if="!isbool(data)">
			<view class="pad10 bdda tac c12">无效的数据</view>
		</view>
		<view class="pos-a l0 r0 t0 b0 flcc bcaf4 c12" v-show="loading && !isbool(data)">
			<text class="fa fa-spinner fa-spin fa-4x"></text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			iri: ''
		},
		data() {
			return {
				loading: true,
				data: '',
				title: '',
				score: '',
				tips: '',
				picsAttach: [],
				selectItem: [],
			}
		},
		methods: {
			selectChoice(item) {
				this.selectItem = item
				this.title = item[0]
				this.score = this.data.startScore * 1 + item[1] * 1
			},
			finish() {
				this.$emit("save", {
					title: this.isbool(this.data.title) ? this.data.title : '数据异常',
					score: this.score,
					tips: this.tips,
					pics: this.picsAttach,
					point:this.iri
				})
			}
		},
		mounted() {
			this.log(this.iri)
			if (this.isbool(this.iri)) {
				this.$api.getRes(this.iri, res => {
					this.data = res
					this.loading = false
				})
				return
			}
		}
	}
</script>

<style>
</style>
